#!/usr/local/bin/perl

$dirtoget="/home/naila/Naila_Thesis/corpus/series_alignment/lower_probably_aligned";
opendir(DD, $dirtoget) || die("Cannot open directory");
@files= readdir(DD);
closedir(DD);

print "Processing files \n";
my $file_name;
@thefiles = sort @files;

print $#thefiles;
$fw_eng =  "/home/naila/Naila_Thesis/corpus/temp_with_new_data/low_prob_aligned_eng.txt";
$fw_urdu = "/home/naila/Naila_Thesis/corpus/temp_with_new_data/low_prob_aligned_urdu.txt";
open FWE,">:utf8",$fw_eng;
open FWU,">",$fw_urdu;

for(my $i=0;$i< @thefiles;$i++)
{
	$f = $thefiles[$i];

	print "Reading file",$f, "\n";
 	unless ( ($f eq ".") || ($f eq "..") || ($f eq ".svn")|| ($f eq ".svn_align.txt") )
	{
		$file_name = join "",$dirtoget,"/",$f;
		open(FF,$file_name) || die("Cannot open file");

		while(<FF>)
		{
    			chomp;
    			my @words = split(/#/,$_);
    			print FWE $words[0];
			print FWE "\n";
			print FWU $words[1];
			print FWU "\n";

		}
			$file_name = "";
			close FF;
	}

}
print "Processing done\n";
close DD;
